package file;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        for (int i = 1; i <= 10; i++) {
            File file = new File("./test" + i + ".txt");
            if (file.exists()) {
                System.out.println("文件已经存在");
            } else {
                file.createNewFile();
                System.out.println("文件已经添加");
            }
        }

        Scanner s = new Scanner(System.in);

        System.out.print("请输入需要删除的文件名:");
        String str = s.next();
        File file = new File("./" + str);
        if (file.exists()) {
            file.delete();
            System.out.println("您所输入的文件已经删除");
        } else {
            System.out.println("您输入的文件不存在");
        }
    }
}
